home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-07-11 | 941 b | 49 lines | [TEXT/MPS ] |
- #
- # znew.mac -- znew for MPW
- #
- # written by Anthony C. Ard, 1993
- #
- # zforce: force a gz extension on all gzip files so that gzip will not
- # compress them twice.
- #
- # This can be useful for files with names truncated after a file transfer.
- # 12345678901234 is renamed to 12345678901.gz
-
- set x "{0}"
- set exit 0
-
- if {#} == 0
- echo "force a ‘.gz’ extension on all gzip files"
- echo "usage: {x} files…"
- set exit 1;
- exit 1;
- end
-
- set res 0
-
- for i in {Parameters}
- if !`exists -f "{i}"`
- echo "{x}: “{i}” not a file"
- set res 1
- continue
- end
- if "{i}" =~ /≈[.-]z∞/; continue; end
- if "{i}" =~ /≈[.-]gz∞/; continue; end
- if "{i}" =~ /≈[.]t[ag]z∞/; continue; end
-
- gzip -vl <"{i}" ≥Dev:Null | grep '^defl' >Dev:Null
- if {Status} == 0
- set new "{i}.gz"
- rename "{i}" "{new}" ≥Dev:Null
- if {Status} == 0
- echo "{i} -- replaced with {new}"
- continue
- end
- set res 1
- echo "{x}: cannot rename {i} to {new}"
- end
- end
-
- set exit 1
- exit {res}
-